home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-06-19 | 1.2 KB | 42 lines |
- package symantec.itools.net;
-
-
- import java.net.URL;
- import java.net.MalformedURLException;
- import symantec.itools.lang.Context;
-
-
- // 05/15/97 CAR Added ieAnchorHack to work around an IE problem with anchor symbols in URLs.
-
- public class RelativeURL
- {
- public static URL getURL(String spec)
- throws MalformedURLException
- {
-
- // InternetExplorer for some reason strips out a single anchor symbol (#)
- // when the URL is passed to showDocument() so we double up the symbol (##)
- if (System.getProperty("java.vendor").startsWith("Microsoft") &&
- spec.indexOf('#') > -1) {
- spec = ieAnchorHack(spec);
- }
-
- URL documentBase = Context.getDocumentBase();
-
- if(documentBase != null && spec.indexOf("//") == -1)
- {
- return new URL(documentBase,spec);
- }
-
- return new URL(spec);
- }
-
- private static String ieAnchorHack(String spec) {
- String str = spec.substring(0, spec.lastIndexOf('#'));
- str += "#";
- str += spec.substring(spec.lastIndexOf('#'));
- return str;
- }
-
-
- }